
package cz.uhk.ppro.response.web;

import java.net.BindException;
import org.apache.commons.fileupload.FileUpload;
import org.springframework.stereotype.Controller;
import org.springframework.web.bind.annotation.ModelAttribute;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RequestMethod;
import org.springframework.web.multipart.MultipartFile;
import org.springframework.web.servlet.ModelAndView;

/**
 *
 * @author Filip Valenta
 */
@Controller
@RequestMapping("upload-resource.do")
public class ResourcesController {

    // TODO: fixme : http://www.ioncannon.net/programming/975/spring-3-file-upload-example/
    // TODO: http://www.mkyong.com/spring-mvc/spring-mvc-file-upload-example/

    /*@RequestMapping(method=RequestMethod.GET)
    protected ModelAndView loadForm() {

        ModelAndView model = new ModelAndView("formResourceUpload");
        model.addObject("fileUpload", new FileUpload());

        return model;
    }

    @RequestMapping(method=RequestMethod.POST)
    public String processUpload(@ModelAttribute("fileUpload") FileUpload file, BindException errors) throws Exception
    {
        MultipartFile multipartFile = (MultipartFile) file.getFile();
        String fileName="";

        if(multipartFile != null){
            fileName = multipartFile.getOriginalFilename();

            System.out.println("jo ulozeno"+multipartFile.getOriginalFilename());

        }

        return "redirect:/resources.do";
    }*/


}
